﻿using Layans.Data;
using Api.Models;
using Api.Models.Group;
using LForum.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Api.Controllers.Group
{
    public class GroupMassageController : Controller
    {
        //LayansContext db = new LayansContext();

        ////
        //// GET: /GroupMassage/
        //public ActionResult Index()
        //{
        //    return View();
        //}

        //public ActionResult DoCreate(GroupMassage groupMassage)
        //{
        //    var massage = new GroupMassage
        //    {
        //        Massage =  Massage,
        //        CreationTime = DateTime.Now,
        //        Avatar = avatars,
        //        user =  username,
        //    };
        //    db.GroupMassages.Add(massage);
        //    db.SaveChanges();
        //    return Redirect("/");
        //}

        //public ActionResult ViewMassage(int postId)
        //{
        //    if(!db.GroupMassages.Any(x => x.Id == postId))
        //    {
        //        return Redirect("/");
        //    }

        //    var massage = db.GroupMassages.Where(x => x.Id == postId)
        //        .Select(x => new GroupFullMassageViewModel
        //        {
        //            Avatar = x.Avatar.avatar,
        //            User = x.user.UserName,
        //            Massage = x.Massage,
        //            CreationTime = x.CreationTime,

        //        }).SingleOrDefault();

        //    massage.Answer = db.GroupMassageAnswers.Where(x => x.Massages.Id == postId)
        //        .Select(y => new GroupMassageAnswerViewModel { 
        //            CreationTIme = y.CreationTime,
        //            Avatar = y.avatar.avatar,
        //            User = y.User.UserName,
        //            Massage = y.Massage,
        //        });
            

        //    return View(massage);
        //}

        //public ActionResult DoAnswer(int massagePostId, string massage)
        //{
        //    var forumPost = db.GroupMassages.FirstOrDefault(x => x.Id == massagePostId);

        //    db.GroupMassageAnswers.Add(new GroupMassageAnswer
        //        {
        //            avatar = avatars,
        //            User = user,
        //            CreationTime = DateTime.Now,
        //            Massage = massage,

        //        });
        //    db.SaveChanges();

        //    return Redirect("/");
        //}


        //public string Massage { get; set; }

        //public Avatar avatars { get; set; }

        //public LForum.Models.ExternalLoginConfirmationViewModel username { get; set; }

        //public LForum.Models.ExternalLoginConfirmationViewModel user { get; set; }
    }
}